//
//  ConfirmOrderAddressCell.m
//  sensen_ios
//
//  Created by pro on 16/2/27.
//  Copyright © 2016年 pro. All rights reserved.
//

#import "ConfirmOrderAddressCell.h"

#define cell_width self.contentView.width
#define cell_height self.contentView.height

@implementation ConfirmOrderAddressCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
        self.contentView.width = SCREEN_WIDTH;
        self.contentView.height = 60;
        [self _initViews];
    }
    
    return self;
}

#pragma mark -- 创建视图 --
- (void)_initViews {
    
    CGFloat x, y, width, height;
    
    // 图标
    x = 15;
    width = 20;
    height = 25;
    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, width, height)];
    imgView.image = [UIImage imageNamed:@"订单详情_地址"];
    [self.contentView addSubview:imgView];
    imgView.center = CGPointMake(imgView.center.x, cell_height / 2);
    
    // 名字
    x = imgView.right + 10;
    y = 10;
    width = cell_width / 2;
    height = 20;
    _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
    _nameLabel.font = FONT(15);
    _nameLabel.text = @"博也科技";
    _nameLabel.textColor = [UIColor darkGrayColor];
    _nameLabel.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:_nameLabel];
    
    // 地址
    y = _nameLabel.bottom;
    width = cell_width - 40 - x;
    _addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
    _addressLabel.font = FONT(12);
    _addressLabel.text = @"浙江省杭州市江干区下沙万亚金沙湖1号2幢1515";
    _addressLabel.textColor = [UIColor darkGrayColor];
    _addressLabel.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:_addressLabel];
    
    // 手机
    y = _nameLabel.top;
    width = _nameLabel.width;
    height = 20;
    _mobileLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
    _mobileLabel.font = FONT(15);
    _mobileLabel.text = @"13157398112";
    _mobileLabel.textColor = [UIColor darkGrayColor];
    _mobileLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_mobileLabel];
    _mobileLabel.right = cell_width - 40;
    
}



#pragma mark - set
- (void)setModel:(AddressModel *)model {
    _model = model;
    [self _layoutViews];
}
- (void)_layoutViews {
    
    _nameLabel.text = _model.contactname;
    
    _mobileLabel.text = _model.mobile;
    
    _addressLabel.text = _model.address;
}
@end
